package com.aba.cms.teacher;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBConnection {
    private static final String URL = "jdbc:mysql://localhost:3306/course_management";
    private static final String USER = "root";
    private static final String PASSWORD = "gsc20050801";

    public static Connection getConnection() throws SQLException {
        // 注册MySQL驱动
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            throw new SQLException("MySQL驱动加载失败", e);
        }
        return DriverManager.getConnection(URL, USER, PASSWORD);
    }
}    